﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace BingleMaps.Controls
{
    public class UserPinListItem : Control
    {
        public event RoutedEventHandler Go, Edit;

        public UserPinListItem()
        {
            DefaultStyleKey = typeof(UserPinListItem);
        }

        public override void OnApplyTemplate()
        {
            ((ButtonBase)GetTemplateChild("GoButton")).Click += (s, e) => { if (Go != null)Go(this, e); };
            ((ButtonBase)GetTemplateChild("EditButton")).Click += (s, e) => { if (Edit != null)Edit(this, e); };
        }

        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(UserPinListItem), null);

        public string Description
        {
            get { return (string)GetValue(DescriptionProperty); }
            set { SetValue(DescriptionProperty, value); }
        }

        public static readonly DependencyProperty DescriptionProperty =
            DependencyProperty.Register("Description", typeof(string), typeof(UserPinListItem), null);

        public Brush ColorTag
        {
            get { return (Brush)GetValue(ColorTagProperty); }
            set { SetValue(ColorTagProperty, value); }
        }

        public static readonly DependencyProperty ColorTagProperty =
            DependencyProperty.Register("ColorTag", typeof(Brush), typeof(UserPinListItem), new PropertyMetadata(Application.Current.Resources["PhoneAccentBrush"]));

        public bool IsChecked
        {
            get { return (bool)GetValue(IsCheckedProperty); }
            set { SetValue(IsCheckedProperty, value); }
        }

		public static readonly DependencyProperty IsCheckedProperty =
			DependencyProperty.Register("IsChecked", typeof(bool), typeof(UserPinListItem), new PropertyMetadata(false));
    }
}
